home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 22
/
Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso
/
Aminet
/
dev
/
amos
/
amos_col.lha
/
AMOS-COL
/
Editor.amos
/
Editor.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1980-01-10
|
19KB
|
854 lines
'
'BY DELTA (based on Ben's Wyatt editor)
'DELTA:
'�ukasz �elezny
'Ul. W�oska 4d/6
'42-612 Tarnowskie G�ry
'Poland
'
'This program required AMOSPro_Delta.Lib
'This file is PUBLIC DOMAIN!
'
'Date: 13.04.1996!
'
Set Buffer 150
BLOK
Trap Screen Close 0 : Hide
Degree
Dim FILE$(100)
Global AN,FILE$(),FI$,ED$,N,PASS
Dim S(359),C(359) : For A=0 To 359 : S(A)=Sin(A)*16384 : C(A)=Cos(A)*16384 : Next A
Global S(),C()
LINES=1000 : L=0 : YPOS=0 : SZE=199 : WKSAZ=0
Dim LINE$(LINES)
Global LINES,TSCRHEIGHT,L,YPOS,FILENAME$,SZE,WSKAZ,ROT,MUZA
Global LINE$()
MUZA=1
Track Play : Track Loop On
_TEXTEDITOR[0]
Edit
Procedure _TEXTEDITOR[SCR]
Screen Open 1,640,256,2,Hires
Wait Vbl
Curs Off : Palette 0,$FFF
Double Buffer : Autoback 0
Screen Open SCR,640,255,4,Hires
Wait Vbl
Cls 0
Dual Playfield 0,1
Colour 9,$AAA
Colour 17,$FF0
Colour 20,$BB0
Colour 24,$880
Colour 31,$660
Sprite 1,128,50,1
Amal 1,"P: Let X=XM-13; Let Y=YM; J P;"
Amal On 1
Screen Display 0,128,37,640,Screen Height
Palette $0,$80,$FFF,,$FFF
Cdown
Cls 0
Cls 2,0,0 To 640,8
'Cls 2,624,8 To 640,Screen Height
TSCRHEIGHT=Screen Height/8-1
Scroll Off
_LMOUSE
Def Scroll 1,0,8 To 624,Screen Height,0,8
Def Scroll 2,0,16 To 624,Screen Height,0,-8
Paper 0 : Pen 2
Menu$(1)=" Project "
Menu$(1,1)=" Load "
Menu$(1,2)=" Save "
Menu$(1,3)=" Save As "
Menu$(1,4)=" Music "
Menu$(1,5)=" About "
Menu$(1,20)=" Quit "
Menu On
_TEXTUPDATE[0]
_CURSPOS
Repeat
If Choice
C1=Choice(1)
C2=Choice(2)
Menu Off
If C1=1
If C2=1
REQ
_LOAD[FI$]
_TEXTUPDATE[YPOS]
End If
If C2=2
_SAVE[FILENAME$]
_TEXTUPDATE[YPOS]
End If
If C2=3
FILENAME$="" : _SAVE[FILENAME$]
_TEXTUPDATE[YPOS]
End If
If C2=4
If MUZA=1
MUZA=0
Track Stop
Else
MUZA=1
Track Play
End If
End If
End If
If C2=5
Screen Hide 0 : Screen Hide 1 : Wait Vbl
Extension_25_0044
Unpack 10 To 5
Colour 17,$FF0
Colour 20,$BB0
Colour 24,$880
Colour 31,$660
Extension_25_0034
Repeat : Until Mouse Key<>0 or Inkey$<>""
Fade 2
Wait 25
Screen Close 5
Screen Show 0 : Screen Show 1
End If
If C1=2
End If
If C1=3
End If
Menu On
Clear Key
End If
X=X Screen(X Mouse) : Y=Y Screen(Y Mouse) : MC=Mouse Click : MK=Mouse Key
If MC=1 and Y>7
XC=X/8 : YC=Y/8
L=YPOS+YC-1
Locate Min(XC,Len(LINE$(L))),YC
End If
I$=Inkey$ : S=Scancode : A=Asc(I$) : SS=Scanshift
If A>0 or S>0 : _CHECK[I$,A,S,SS] : End If
If WSKAZ=0
SZE=SZE-2
_ZOOMGRID
If SZE=<25
WSKAZ=1
End If
End If
If WSKAZ=1
SZE=SZE+2
_ZOOMGRID
If SZE=>300
WSKAZ=0
End If
End If
Until C1=1 and C2=20
End Proc
Procedure _TEXTUPDATE[ST]
' St=Start of text to print
Cls 0,0,8 To 624,Screen Height
X=X Curs : Y=Y Curs
Paper 0 : Pen 2
For YPL=ST To ST+TSCRHEIGHT-1
Locate 0,YPL-ST+1
Print LINE$(YPL)
Next YPL
Locate X,Y
End Proc
Procedure _LOAD[FILE$]
On Error Proc BAD
Resume Label KONIEC
If FILE$<>""
Open In 1,FILE$
DLUG=Lof(1)
Close
Reserve As Chip Data 12,DLUG
Bload FILE$,12
PL=Start(12)
For N=0 To LINES
Extension_15_0080
LINE$(N)=""
If PL<Start(12)+Length(12)
LINE$(N)=Peek$(PL,78,Chr$(10))
Add PL,Len(LINE$(N))+1
End If
Next N
Erase 12
L=0 : YPOS=0 : X=0 : Y=1 : ST=0 :
Locate 0,1 : Cline
Cls 0,0,8 To 624,Screen Height
_CURSPOS
End If
KONIEC:
End Proc
Procedure _SAVE[FILENAME$]
On Error Proc BAD
Resume Label KONIEC
X=X Curs : Y=Y Curs
If FILENAME$=""
REQ:
FILENAME$=FI$
End If
Reserve As Chip Data 12,78*LINES
PL=Start(12)
For N=0 To LINES
Extension_15_0080
Poke$ PL,LINE$(N)+Chr$(10)
Add PL,Len(LINE$(N))+1
Next N
Bsave FILENAME$,Start(12) To PL
Erase 12
KONIEC:
Locate X,Y
End Proc
Procedure _LMOUSE
Limit Mouse 130,39 To 128+318,37+Screen Height-2
End Proc
Procedure _CHECK[I$,A,S,SS]
On Error Proc BAD
Resume Label KONIEC
X=X Curs
' Normal Key
If A>31 and Len(LINE$(L))<77
A1$=Left$(LINE$(L),X)
A2$=Right$(LINE$(L),Len(LINE$(L))-X)
LINE$(L)=A1$+I$+A2$
Inc X
Locate 0,Y Curs
Print LINE$(L);
Locate X,Y Curs
End If
' Backspace+shift
If A=8 and SS<>0 and X=Len(LINE$(L))
LINE$(L)=""
Locate 0,Y Curs
X=0
Cline
Locate X,Y Curs
Goto SKIP
End If
' Backspace+shift
If A=8 and SS<>0 and X>0 and X<Len(LINE$(L))
LINE$(L)=Right$(LINE$(L),Len(LINE$(L))-X)
Locate 0,Y Curs
X=0
Cline
Print LINE$(L)+" ";
Locate X,Y Curs
Goto SKIP
End If
' Backspace
If A=8 and(L>0 or X>0)
If X=0
A1$=LINE$(L-1)
A2$=LINE$(L)
If Len(A1$+A2$)<=77
For N=L+1 To LINES
LINE$(N-1)=LINE$(N)
Next N
LINE$(LINES)=""
LINE$(L-1)=A1$+A2$
Dec L
If Y Curs=1
Curs Off : Wait Vbl
Scroll 1 : Dec YPOS
Cls 0,0,8 To 624,16
Locate 0,1 : Print LINE$(L);
Curs On
Else Cup
End If
Y=Y Curs
Def Scroll 3,0,Y*8+8 To 624,Screen Height,0,-8
Scroll 3
Locate 0,Y : Print LINE$(L);
Cls 0,0,248 To 624,256
Locate 0,TSCRHEIGHT : Print LINE$(YPOS+TSCRHEIGHT-1);
Locate Len(A1$),Y
Clear Key
End If
Else
A1$=Left$(LINE$(L),X-1)
A2$=Right$(LINE$(L),Len(LINE$(L))-X)
LINE$(L)=A1$+A2$
Dec X
Locate 0,Y Curs
Print LINE$(L)+" ";
Locate X,Y Curs
End If
End If
' Delete + shift
If S=70 and SS<>0 and X>0 and X<Len(LINE$(L))
LINE$(L)=Left$(LINE$(L),X)
Locate 0,Y Curs
Cline
Print LINE$(L)+" ";
Locate X,Y Curs
Goto SKIP
End If
' Delete + shift
If S=70 and SS<>0 and X=0
LINE$(L)=""
Locate 0,Y Curs
Cline
Locate X,Y Curs
Goto SKIP
End If
' Delete
If S=70 and X<Len(LINE$(L))
A1$=Left$(LINE$(L),X)
A2$=Right$(LINE$(L),Len(LINE$(L))-X-1)
LINE$(L)=A1$+A2$
Locate 0,Y Curs
Print LINE$(L)+" ";
Locate X,Y Curs
End If
' Return
If A=13 and LINE$(LINES)=""
A1$=Left$(LINE$(L),X)
A2$=Right$(LINE$(L),Len(LINE$(L))-X)
LINE$(L)=A1$
For N=LINES-1 To L+1 Step -1
LINE$(N+1)=LINE$(N)
Next N
If Y Curs=TSCRHEIGHT
Curs Off : Wait Vbl
Scroll 2 : Inc YPOS
Cls 0,0,Screen Height-8 To 624,Screen Height
Locate 0,TSCRHEIGHT : Print LINE$(L);
Cup : Curs On
End If
Inc L
MV=0
If Y Curs<TSCRHEIGHT : Locate 0,Y Curs+1
Else Inc YPOS
End If
LINE$(L)=A2$
Y=Y Curs
Def Scroll 3,0,Y*8 To 624,Screen Height,0,8
Curs Off : Wait Vbl
Scroll 3
Cls 0,0,Y*8-8 To 624,Y*8+8
Locate 0,Y-1 : Print LINE$(L-1);
Locate 0,Y : Print LINE$(L);
If Y<>TSCRHEIGHT : Locate 0,Y+1 : Print LINE$(L+1); : End If
Locate 0,Y
Curs On
Clear Key
End If
' Cursor left
If A=29 and X>0
If SS>0 : Locate 0,Y Curs
Else Cleft
End If
End If
' Cursor right
If A=28 and X<Len(LINE$(L))
If SS>0 : Locate Len(LINE$(L)),Y Curs
Else Cright
End If
End If
' Cursor up
If A=30 and L>0 and SS=>1 and SS<=2
For PPPP=1 To TSCRHEIGHT
Dec L
If Y Curs=1
Curs Off : Wait Vbl
Scroll 1 : Dec YPOS
Cls 0,0,8 To 624,16
Locate 0,1 : Print LINE$(L);
Curs On
Else Cup
End If
If X>Len(LINE$(L)) : X=Len(LINE$(L)) : End If
Locate X,Y Curs
Exit If L=0
Next
Clear Key
End If
If A=30 and L>0 and SS=0
Dec L
If Y Curs=1
Curs Off : Wait Vbl
Scroll 1 : Dec YPOS
Cls 0,0,8 To 624,16
Locate 0,1 : Print LINE$(L);
Curs On
Else Cup
End If
If X>Len(LINE$(L)) : X=Len(LINE$(L)) : End If
Locate X,Y Curs
Clear Key
End If
' Cursor down
If A=31 and L<LINES and SS=0
Inc L
If Y Curs=TSCRHEIGHT
Curs Off : Wait Vbl
Scroll 2 : Inc YPOS
Cls 0,0,Screen Height-8 To 624,Screen Height
Locate 0,TSCRHEIGHT : Print LINE$(L);
Curs On
Else Cdown
End If
If X>Len(LINE$(L)) : X=Len(LINE$(L)) : End If
Locate X,Y Curs
Clear Key
End If
If A=31 and L<LINES and SS=>1 and SS<=2
For PPP=1 To TSCRHEIGHT
Inc L
If Y Curs=TSCRHEIGHT
Curs Off : Wait Vbl
Scroll 2 : Inc YPOS
Cls 0,0,Screen Height-8 To 624,Screen Height
Locate 0,TSCRHEIGHT : Print LINE$(L);
Curs On
Else Cdown
End If
If X>Len(LINE$(L)) : X=Len(LINE$(L)) : End If
Locate X,Y Curs
Clear Key
Exit If L=LINES
Next
End If
KONIEC:
SKIP:
_CURSPOS
End Proc
Procedure _CURSPOS
X=X Curs : Y=Y Curs
Locate 0,0 : Paper 0
Print Using "COL: ### ";X;
Print Using "LIN: ### ";L;
'Print Using " ##";Y
Locate X,Y : Paper 0
End Proc
Procedure _ZOOMGRID
On Error Proc BAD
Resume Label KONIEC
Screen 1
Cls 0
Add ROT,3,0 To 359
C=C(ROT) : MC=(500*C)/16384
S=S(ROT) : MS=(500*S)/16384
For YY=-200 To 200 Step SZE
NC=(YY*C)/16384
NS=(YY*S)/16384
Draw 320-MC-NS,100+NC-MS To 320+MC-NS,100+NC+MS
Draw 320+NC+MS,100-MC+NS To 320+NC-MS,100+MC+NS
Next YY
Screen Swap
Screen 0
KONIEC:
Pop Proc
End Proc
Procedure BAD
Screen Open 5,640,20,8,Hires : Curs Off : Flash Off : Cls 0
Screen Display 5,,,,10
For I=0 To 7 : Colour I,I*$222 : Next I
Double Buffer : Autoback 0 : Paper 0
XXX=1 : YYY=0 :
A$=Err$(Errn)
L=Len(A$)
For I=1 To Len(A$)+7 : B=I-7 : B=Max(0,B) : C=I+1 : C=Min(C,L)
For J=C To B Step -1 : A=I-(J-1) : A=Min(Max(A,0),7)
Pen A : Print At(XXX,YYY),Left$(A$,J) : Next J : Screen Swap 5 : Wait Vbl : Next I
Repeat
If WSKAZ=0
SZE=SZE-2
_ZOOMGRID
If SZE=<25
WSKAZ=1
End If
End If
If WSKAZ=1
SZE=SZE+2
_ZOOMGRID
If SZE=>300
WSKAZ=0
End If
End If
Until Mouse Key<>0 or Inkey$<>""
Screen Close 5
Resume Label
End Proc
'
Procedure REQ
Screen Open 3,640,200,4,Hires : Curs Off : Flash Off : Cls 0
Colour 17,$FF0
Colour 20,$BB0
Colour 24,$880
Colour 31,$660
Palette $AAA,$0,$FFF,$68A
PATH$=Dir$
FILT$=""
PASS=0
FR[PATH$,FILT$,"Please Select","A Program..."]
Screen Close 3 : _LMOUSE
End Proc
Procedure FR[PATH$,FILT$,H1$,H2$]
'
Screen Open 7,360,160,4,Hires : Curs Off : Flash Off : Cls 0
Screen Display 7,200,70,, : Palette $AAA,$0,$FFF,$68A
Colour 17,$FF0
Colour 20,$BB0
Colour 24,$880
Colour 31,$660
Limit Mouse 194,75 To 365,226
Gosub _SETUP_SCREEN
If PASS=0
PASS=1
End If
If PASS=1
Goto 55
End If
1
Locate 2,14 : Print String$(" ",37) : FI$=""
For Z=1 To H+1
FILE$(Z)=""
Next Z
For Z=8 To 8+H
Locate 2,Z
Print String$(" ",37)
Next Z
Gosub _GET_DIR
55
H=4 : P=1 : OK=1 : FF=1
Gosub _DISPLAY_DIRECTORY
Gosub _DISPLAY_WILDCARD
Do
'
' *** SELECT FILE
'
For Z=1 To 5
R[16,64+(Z*8)-8,311,71+(Z*8)-8] : If AN>0 Then FF=P+(Z-1) : OK2=1
Next Z
'
' *** DISPLAY DIRECTORY & PATH
'
If OK=1
Gosub _DISPLAY_DIR
Gosub _SCROLLY
End If
'
' *** SELECT FILE or GET DIRECTORY
'
If OK2=1
If Mid$(FILE$(FF),30,5)<>"(Dir)"
Locate 2,14 : Print String$(" ",37)
Z$=FILE$(FF) : Gosub _SHORTEN : FI$=Z$
Locate 2,14 : Print FI$
Else
Z$=FILE$(FF) : Gosub _SHORTEN
If Exist(PATH$+Z$)
PATH$=PATH$+Z$+"/"
OK2=0 : Goto 1
End If
End If
OK2=0
End If
'
' *** ENTER NEW DIRECTORY
'
R[12,45,315,59]
If AN>0 : Locate 2,6 : Print String$(" ",37)
ED[PATH$,100,2,6,37,0]
If(Right$(ED$,1)<>"/") and(Right$(ED$,1)<>":") : ED$=ED$+"/" : End If
If Exist(ED$) : PATH$=ED$ : Goto 1 : End If
Gosub _DISPLAY_DIRECTORY
End If
'
' *** ENTER FILENAME & EXIT
'
R[12,109,315,123]
If AN>0 : T$="" : Locate 2,14 : Print String$(" ",37)
ED[FI$,100,2,14,37,0]
If ED$=""
Goto 3
End If
If Exist(PATH$+ED$) : FI$=PATH$+ED$ : Goto FINISH : End If
Locate 2,14 : Print String$(" ",37)
End If
3
'
' *** ENTER WILDCARD & GET NEW DIR
'
R[260-8,133,315,147]
If AN>0
ED[FILT$,100,32,17,6,0] : FILT$=ED$
Goto 1 : End If
'
' *** UP ONE FILE
'
R[324,133,339,147]
If AN>0 and P<N-H : Inc P : OK=1 : End If
'
' *** DOWN ONE FILE
'
R[324,13,339,27]
If AN>0 and P>1 : Dec P : OK=1 : End If
'
' *** CANCEL
'
R[12,133,83,147]
If AN>0 Then FI$="" : Goto FINISH
'
' *** PARENT
'
R[124-32,133,203-32-8,147]
If AN>0
If PATH$<>""
For Z=Len(PATH$)-1 To 1 Step -1
A$=Mid$(PATH$,Z,1)
If(A$="/") or(A$=":") : PATH$=Left$(PATH$,Z) : Exit : End If
Next
End If
Goto 1
End If
'
' *** O.K!
'
R[244-64-8,133,315-64-8,147]
If AN>0
FI$=PATH$+FI$
Goto FINISH
End If
'
Loop
'
' *********************************
_SCROLLY:
Ink 0 : Bar 325,30 To 338,130
If N>(H+1)
Y1=30+(100*(P-1))/N
Y2=Min(30+100,Y1+(100*H)/N)
B[325,Y1,338,Y2,"",1]
Else
B[325,30,338,130,"",1]
End If
Return
'
_SHORTEN:
For Z=29 To 1 Step -1
If Mid$(Z$,Z,1)<>" " : Z$=Left$(Z$,Z) : Exit : End If
Next Z
Return
'
_GET_DIR:
N=0
A$=Dir First$(PATH$+FILT$)
While A$<>""
N=N+1
If Left$(A$,1)<>"*"
FILE$(N)=Mid$(Left$(A$,Len(A$)),2)
Else
FILE$(N)=Mid$(A$,2)
Mid$(FILE$(N),30,5)="(Dir)"
End If
A$=Dir Next$
Wend
Return
'
_DISPLAY_DIR:
Y=8
For Z=P To P+H
Locate 2,Y
Print FILE$(Z)
Inc Y
Next
OK=0
Return
'
_DISPLAY_DIRECTORY:
Locate 2,6 : Print String$(" ",37)
Locate 2,6 : Print Left$(PATH$,37)
Return
'
_DISPLAY_WILDCARD:
Locate 32,17 : Print String$(" ",7)
Locate 32,17 : Print Left$(FILT$,7) : Return
'
_SETUP_SCREEN:
Pen 1 : Paper 0
T[1,1,42,18,"",1] : Rem Main Border
T[41,2,1,1,"<",1] : Rem Back 1 File
T[41,17,1,1,">",1] : Rem One 1 File
T[41,4,1,12,"",0] : Rem Scrolly Thing
Set Text 2
T[2,2,37,1,H1$,1] : Rem Heading One
T[2,4,37,1,H2$,1] : Rem Heading Two
Set Text 0
T[2,6,37,1,"",0] : Rem Display Directory
T[2,8,37,5,"",1] : Rem Display Files
T[2,14,37,1,"",0] : Rem Display File
T[2,17,8,1,"CANCEL",1]
T[12,17,8,1,"PARENT",1]
T[22,17,8,1,"O.K!",1]
T[32,17,7,1,"",0]
Return
'
FINISH:
Screen Close 7
'
End Proc
Procedure R[X1,Y1,X2,Y2]
AN=False : X4=X Screen(X Mouse) : Y4=Y Screen(Y Mouse)
If X4<X1 or X4>X2 or Y4<Y1 or Y4>Y2 Then Pop Proc
Gr Writing 2
While Mouse Key>0
X4=X Screen(X Mouse) : Y4=Y Screen(Y Mouse)
If X4>X1 and X4<X2 and Y4>Y1 and Y4<Y2 and AN=False Then Bar X1,Y1 To X2,Y2 : AN=Mouse Key
If AN Then If X4<X1 or X4>X2 or Y4<Y1 or Y4>Y2 Then Bar X1,Y1 To X2,Y2 : AN=False
Wend
If AN Then Bar X1,Y1 To X2,Y2
Gr Writing 1
End Proc
Procedure B[X1,Y1,X2,Y2,A$,IN]
If IN=1
C1=2
C2=1
Else
C1=1
C2=2
End If
Ink 0
Bar X1,Y1 To X2,Y2
Ink C1
Box X1,Y1 To X2,Y2
Ink C2
Polyline X1,Y2 To X2,Y2 To X2,Y1+1
If A$<>""
W=Text Length(A$)
X7=(((X2-X1)/2)+X1)-(W/2)
Ink 1,0
Text X7,((Y2-Y1)/2)+Y1+3,A$
End If
End Proc
Procedure T[X,Y,W,H,T$,IN]
X1=(X*8)-4 : Y1=(Y*8)-3 : X2=X1+(W*8)+7 : Y2=Y1+(H*8)+6
B[X1,Y1,X2,Y2,T$,IN]
End Proc
Procedure ED[ED$,XC,XX,YY,SX,MN]
PX=0 : L=Len(ED$) : If L>=SX : PX=L-SX : End If
XC=Max(0,XC) : XC=Min(XC,L)
Curs On
Do
Gosub _DED
Repeat
A$=Inkey$ : S=Scancode
If Mouse Key=1
X=(X Screen(X Mouse))/8-XX
If X>=MN and X<=L : XC=X : Gosub _DED : Wait Vbl : End If
End If
Until A$<>""
F=1
If A$=Chr$(13) : Exit : End If
If A$=Chr$(27) : ED$="_Esc_" : Exit : End If
If S=65 and XC+PX>MN
ED$=Left$(ED$,XC+PX-1)+Mid$(ED$,PX+XC+1) : E=1 : L=L-1
S=79
End If
If S=70 and XC+PX<L
ED$=Left$(ED$,XC+PX)+Mid$(ED$,PX+XC+2) : E=1 : L=L-1 : F=0
End If
If S=79 and PX+XC>MN
F=0
If XC=0
PX=PX-1
Else
XC=XC-1
End If
End If
If S=78 and PX+XC<L
F=0
If XC=SX
PX=PX+1
Else
XC=XC+1
End If
End If
If F
If A$>=" "
ED$=Left$(ED$,PX+XC)+A$+Mid$(ED$,PX+XC+1) : L=L+1
If L>SX
If XC>=SX
PX=PX+1
Else
XC=XC+1
End If
Else
XC=XC+1
End If
End If
End If
Loop
Curs Off
Goto _END
'
_DED:
Locate XX,YY : Print Mid$(ED$,PX+1,SX);
If E : If X Curs<XX+SX : Print " "; : E=0 : End If : End If
Locate Min(XX+XC,XX+SX-1),YY
Return
'
_END:
End Proc
'
Procedure BLOK
Amos Lock
Break Off
Close Workbench
Request Off
Hide
End Proc